import axios from 'axiosInstance'

//封装axios请求
const request = (options) => {
    /*options:{
    url:"/order/receive/queryOrder/queryOrderListInfo",
    method: 'post'.
    data,
    ...options,}*/
    return new Promise((resolve, reject) => {
        //如果是get请求，将data转为params
        if (options.method === 'get') {
            options.params = options.data
        }
        //如果是post请求，将data转为data
        if (options.method === 'post') {
            options.data = options.data 
        }
        
        axios(options)
            .then(res => {
                resolve(res.data)
            })
            .catch(err => {
                reject(err)
            })
    })
    return axios(options)
}